
import { useEffect,useState } from 'react';
import axios from 'axios';
import { Space, Table, Button} from 'antd';
import type { ColumnsType } from 'antd/es/table';

interface DataType {
  id: number;
  name: string;
  age: number;
 sex: string;

}
const columns: ColumnsType<DataType> = [
  {
    title: 'Name',
    dataIndex: 'name',
    key: 'name',
    render: text => <a>{text}</a>,
  },
  {
    title: 'Age',
    dataIndex: 'age',
    key: 'age',
  },
  {
    title: 'Sex',
    dataIndex: 'sex',
    key: 'sex',
  },
  {
    title: 'Action',
    key: 'action',
    render: () => (
      <Space size="middle">
        {/* <Button>Invite {record.name}</Button> */}
        <Button type="primary">Delete</Button>
      </Space>
    ),
  },
];



const http = axios.create({
  baseURL: 'http://127.0.0.1:7001',
  timeout: 2000,
  headers: { 'X-Custom-Header': 'foobar' }
});
function App () {
  const [studentmessage,setmessage]=useState<DataType[]>()

   const getusermessage= async()=> {
    const res = await http.get('/findallstudents') 
    console.log(res.data)
    setmessage(res.data)
  } 
   
    useEffect(() => {
    getusermessage()
            }, [])
  return(
    <div>
   <Table columns={columns} dataSource={studentmessage} />;
    </div>
    )}
   
export default App;